package com.ddf.publics.service.impl;

import com.ddf.publics.entity.LoanApplication;
import com.ddf.publics.dao.LoanApplicationDao;
import com.ddf.publics.service.LoanApplicationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 借贷申请表(LoanApplication)表服务实现类
 *
 * @author norman
 * @since 2020-06-14 20:57:33
 */
@Service
public class LoanApplicationServiceImpl implements LoanApplicationService {
    @Resource
    private LoanApplicationDao loanApplicationDao;

    /**
     * 通过ID查询单条数据
     *
     * @param lId 主键
     * @return 实例对象
     */
    @Override
    public LoanApplication queryById(Integer lId) {
        return this.loanApplicationDao.queryById(lId);
    }

    @Override
    public List<LoanApplication> queryByObj(LoanApplication loanApplication) {
        List<LoanApplication> list = loanApplicationDao.queryAll(loanApplication);
        return list;
    }

    @Override
    public List<LoanApplication> queryByUserId(Integer user_Id) {
        return this.loanApplicationDao.queryByUserId(user_Id);
    }

    /**
     * 查询所有数据
     *
     * @return 对象列表
     */
    @Override
    public List<LoanApplication> queryAllList() {
        return this.loanApplicationDao.queryAllList();
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<LoanApplication> queryAllByLimit(int offset, int limit) {
        return this.loanApplicationDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param loanApplication 实例对象
     * @return 实例对象
     */
    @Override
    public LoanApplication insert(LoanApplication loanApplication) {
        this.loanApplicationDao.insert(loanApplication);
        return loanApplication;
    }

    /**
     * 修改数据
     *
     * @param loanApplication 实例对象
     * @return 实例对象
     */
    @Override
    public LoanApplication update(LoanApplication loanApplication) {
        this.loanApplicationDao.update(loanApplication);
        return this.queryById(loanApplication.getLId());
    }

    /**
     * 通过主键删除数据
     *
     * @param lId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer lId) {
        return this.loanApplicationDao.deleteById(lId) > 0;
    }

    @Override
    public int queryOrderById(Integer id) {
        return this.loanApplicationDao.queryOrderById(id);
    }
}